package kd.hisAlarmConsumerRibbon.controller;

import kd.hisAlarmConsumerRibbon.service.RibbonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.loadbalancer.LoadBalancerClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author：双
 * @time: 2020-02-16 14:16
 * @description:
 * @params: $
 * @return:$
 **/
@RestController
public class RibbonController {

	@Autowired
	RibbonService ribbonService;
	
	@Autowired
	private LoadBalancerClient LoadBalancer;
	
	@GetMapping("/hi")
	public String hi(@RequestParam(required = false,defaultValue = "双") String name)
	{
		return  ribbonService.hi(name);
	}
	
	@GetMapping("/testRibbon")
	public String testRibbon()
	{
		ServiceInstance serviceInstance= LoadBalancer.choose("his-alarm-server");
		return serviceInstance.getHost()+":"+ serviceInstance.getPort();
	}
}
